home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
x11
/
strategy
/
shanghai.000
/
shanghai
/
shanghai-1.0
/
board.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-30
|
3KB
|
99 lines
#include "game.h"
#ifndef __BOARD_H__
#define __BOARD_H__
#include <sys/time.h>
#include "forms.h"
#include "gui.h"
#include "icondata.h"
#include "mapdata.h"
typedef struct {
int seed;
int remain;
int matchcount;
int time0,time1,time2;
int rank;
int scoremode;
enum dsStatus status;
} InfoBoxRec;
typedef struct boardrec {
Display *disp;
Drawable win;
FD_board *board;
int paused;
int boardnumeditable;
int ox,oy,ow,oh;
int seed;
unsigned char occ[144];
unsigned char ideal[144],weight[144];
unsigned char lookup[144];
unsigned char history[144],histstep[144],histpos;
unsigned char inverted[144];
unsigned char sel0,sel1;
int remain;
int matchcount;
struct timeval tv;
int time;
int rank;
int scoremode;
int isfastgame;
DepthScanRec depthscan;
InfoBoxRec infobox;
} BoardRec;
#ifdef __GNUC__
#define min(x,y) ({typeof(x) _x=(x);typeof(y) _y=(y); _x > _y ? _y : _x; })
#define max(x,y) ({typeof(x) _x=(x);typeof(y) _y=(y); _x > _y ? _x : _y; })
#define sqr(x) ({typeof(x) _x=(x); _x*_x;})
#define cubic(x) ({typeof(x) _x=(x); _x*_x*_x;})
extern __inline__ int intersect(int x1,int y1,int w1,int h1,
int x2,int y2,int w2,int h2,
int *x3,int *y3,int *w3,int *h3)
{
*x3 = max(x1,x2);
*y3 = max(y1,y2);
*w3 = min(x1+w1-1,x2+w2-1) - *x3 + 1;
*h3 = min(y1+h1-1,y2+h2-1) - *y3 + 1;
return((*w3 > 0) && (*h3 > 0));
}
extern __inline__ void tile_pos(int pos,int *x,int *y,int *w,int *h,
int *ox,int *oy,int *ow,int *oh)
{
int ix,iy;
ix = (board[pos].x*(ICON_WIDTH-DIM3DX-1))/2 + DIM3DX*board[pos].depth;
iy = (board[pos].y*(ICON_HEIGHT-DIM3DY-1))/2 - DIM3DY*board[pos].depth;
if ( x) *x = ix+DIM3DX;
if ( y) *y = iy+SHADOWY;
if ( w) *w = ICON_WIDTH-DIM3DX;
if ( h) *h = ICON_HEIGHT-DIM3DY;
if (ox) *ox = ix;
if (oy) *oy = iy;
if (ow) *ow = ICON_WIDTH+SHADOWX;
if (oh) *oh = ICON_HEIGHT+SHADOWY;
return;
}
#else
#define __inline__
#define min(x,y) ((x) > (y) ? (y) : (x))
#define max(x,y) ((x) > (y) ? (x) : (y))
#define sqr(x) ((x)*(x))
#define cubic(x) ((x)*(x)*(x))
int intersect(int x1,int y1,int w1,int h1,
int x2,int y2,int w2,int h2,
int *x3,int *y3,int *w3,int *h3);
void tile_pos(int pos,int *x,int *y,int *w,int *h,
int *ox,int *oy,int *ow,int *oh);
#endif
void draw_area(int x,int y,int w,int h,BoardRec *board_rec);
void draw_all_tiles(BoardRec *board_rec);
void update_info_box(BoardRec *board_rec);
void deactivate_board_num(BoardRec *board_rec);
FD_board *new_board(void);
#endif